home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10044 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: EU.net!sun4nl!xs4all!falstaff
  2. From: falstaff@xs4all.nl (Falstaff)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: goto
  5. Date: 15 Mar 1996 10:21:41 GMT
  6. Organization: XS4ALL, networking for the masses
  7. Message-ID: <4ibgbl$o8r@news.xs4all.nl>
  8. References: <Pine.OSF.3.91.960313102715.10701D-100000@io.UWinnipeg.ca> <wpmills.826820253@wpmills>
  9. NNTP-Posting-Host: xs1.xs4all.nl
  10. X-Newsreader: NN version 6.5.0 #666 (NOV)
  11.  
  12. wpmills@midusa.net (W. Paul Mills) writes:
  13.  
  14. >Bill Simpson <wsimpson@uwinnipeg.ca> writes:
  15.  
  16. >>There was a goto thread lately, and my problem is to state this algorithm 
  17. >>cleanly without gotos (which I think is easy, but my attempts have been 
  18. >>failures).
  19.  
  20. >>0. x=0;
  21. >>1. x+=erand(maxmean);
  22. >>2. if (urand2()>rate(x)/maxrate)
  23. >>    goto step 1
  24. >>3. if (x<=XMAX)
  25. >>    {
  26. >>    setdot(x,y,z);
  27. >>    goto step 1
  28. >>    }
  29.  
  30. >x = 0
  31. >do {
  32. >    x += erand(maxmean);
  33. >    if (urand2() > rate(x) / maxrate) continue;
  34. >    setdot(x, y, z);
  35. >   } while ( x < XMAX);
  36.  
  37. No, this will call setdot() one time too much (when x>XMAX just before
  38. exiting the loop).
  39.  
  40. Frank
  41. --
  42. The famous GIICM now on line:  http://www.xs4all.nl/~falstaff/GIICM.html
  43. ------------------------------------------------------------------------
  44. Frank A. Vorstenbosch        +31-(70)-355 5241        falstaff@xs4all.nl
  45.